Repository navigation
Conversation
There are some special locators for searching target window: string 'main' (default): select the main window; string 'current': just return current window handle; a single window handle: directly select window by handle; string 'new': select new opened window assuming it is last-position indexed (no iframe) a past list of window handles: select new window by excluding past window handle list See 'Get Window Handles' to get the past list of window handles
add: from selenium.common.exceptions import NoSuchWindowException
change current to self, fix exception proceeding
enable: select by handle, list all handles, select new by excluding old handle list, close window and select
This was referenced May 14, 2015
Contributor
|
So I like most of this. I'm not so sure about the close and select keyword though. It's nice, but it seems redundant and we already have so many keywords. @emanlove would you take a look at this? |
Contributor
|
Hey @divfor, do you think the |
Contributor
Author
|
it is not a must and can be written as a user keyword. I will remove it. |
Merged
Contributor
|
Closing this in favor of #407. |
Contributor
Author
|
I create a new PR #407 to resolve conflicts - as I tried to rebase my master but failed, so I re-clone rtomac/master |
Member
|
I agree separate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code changes:
added 'Close Window And Select' to simplify two steps of 'Close Window' + 'Select Window'
added 'List Windows' to return all current handles;
enable 'Select Window' to always return the handle of window it is selecting from, and only return handle if 'self' as locator;
enriched 'Select Window' to select any opened window by a window handle;
enriched 'Select Window' to select new window by excluding a list of earlier window handles;
Background:
It is very useful to surface window handle to users that want to have the 'correct way' - comparing window handle sets, to switch window. If we do this way, the fix here for 'Close Window' is not required. instead, my new proposal is to update 'Select Window' and add 2 keywords:
Close Window And Select | locator=NoneThis will close current window and then switch to window if locator is given. locator can be name, title, url, handle, ..., the same as 'Select Window' requires.
${previous_window}= | Select Window | locator=NoneThis will switch to window matching locator and return previous window's handle. locator can be name, title, url, handle of target window, or a handle list to exclude in order to find new window. If locator is 'self', only return current window handle.
${window_list}= | List WindowsThis will return a list of all opened window handles in same session not assuming its order.
Above changes should not impact existing usage of 'Close Window' and 'Select Window', and can offer the strict 'correct way' for using handle to switch window.
example 1:
A user should save main window handle in the beginning if required:
A user can switch to correct window like below:
One more consideration:
should we also offer the additional simplified way to select the last-position indexed window as new window without the need to comparing with old window handles? The doc can prompt user to use strict way to select new window if the simplified way does not work for him/her. From my experiences the simplified way will be correct in 99% cases.
${parent_window}= | Select Window | new